package com.fqgj.xjd.user.client.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午11:52
 */
public enum UserLiveDurationEnum {
    UNDER_SIX_MONTH(1,"6个月以下"),
    SIX_TO_ONE_YEAR(2,"6-12个月"),
    ONE_TO_THREE_YEAR(3,"1-3年"),
    MORE_THEN_THREE_YEAR(4,"3年以上");

    private Integer type;
    private String desc;

    UserLiveDurationEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public UserLiveDurationEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public UserLiveDurationEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (UserLiveDurationEnum enumObj : UserLiveDurationEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }
    
    public static UserLiveDurationEnum getEnumByType(Integer type) {
        UserLiveDurationEnum userLiveDurationEnum = null;
        for (UserLiveDurationEnum enumObj : UserLiveDurationEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userLiveDurationEnum = enumObj;
                break;
            }
        }
        return userLiveDurationEnum;
    }
    
    public static UserLiveDurationEnum getEnumByDesc(String desc) {
        UserLiveDurationEnum userLiveDurationEnum = null;
        for (UserLiveDurationEnum enumObj : UserLiveDurationEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userLiveDurationEnum = enumObj;
                break;
            }
        }
        return userLiveDurationEnum;
    }
}
